//
//  Macros.h
//  MobileProject 常见的配置项
//
//  Created by wujunyang on 16/1/5.
//  Copyright © 2016年 gfeng. All rights reserved.
//

/*是否为IPX*/
#define kDevice_Is_iPhoneX \
({BOOL isPhoneX = NO;\
if (@available(iOS 11.0, *)) {\
isPhoneX = [[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom > 0.0;\
}\
(isPhoneX);})

/*是否为手机*/
#define kIs_iphone (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
/*是否iPad*/
#define kIsPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)

/*状态栏高度*/
#define kStatusBarHeight (CGFloat)(kDevice_Is_iPhoneX?(44.0):(20.0))
/*导航栏高度*/
#define kNavBarHeight (44)
/*状态栏和导航栏总高度*/
#define kNavBarAndStatusBarHeight (CGFloat)(kDevice_Is_iPhoneX?(88.0):(64.0))
/*TabBar 高度*/
#define kTabBarHeight (CGFloat)(51)
/*TabBar 总高度*/
#define kTabBarSafeHeight (CGFloat)(kTabBarHeight + kBottomSafeHeight)
/*顶部安全区域远离高度*/
#define kTopBarSafeHeight (CGFloat)(kDevice_Is_iPhoneX?(44.0):(0))
/*底部安全区域远离高度*/
#define kBottomSafeHeight (CGFloat)(kDevice_Is_iPhoneX?(34.0):(0))
/*iPhoneX的状态栏高度差值*/
#define kTopBarDifHeight (CGFloat)(kDevice_Is_iPhoneX?(24.0):(0))
/*导航条和Tabbar总高度*/
#define kNavAndTabHeight (kNavBarAndStatusBarHeight + kTabBarHeight)


#define __WEAK_SELF_YLSLIDE     __weak typeof(self) weakSelf = self;
#define __STRONG_SELF_YLSLIDE   __strong typeof(weakSelf) strongSelf = weakSelf;


// MainScreen Height&Width
#define Main_Screen_Height      [[UIScreen mainScreen] bounds].size.height
#define Main_Screen_Width       [[UIScreen mainScreen] bounds].size.width
#define Main_Screen_Bounds      [[UIScreen mainScreen] bounds]

#define Screen_Max_Length (MAX(Main_Screen_Width, Main_Screen_Height))
#define Screen_Min_Length (MIN(Main_Screen_Width, Main_Screen_Height))

#define keyWindow_wl            [UIApplication sharedApplication].keyWindow


//状态栏加载网络请求的小菊花
#define showNetWork_WL [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
#define clossNetWork_WL [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;

//字符串是否为空
#define kStringIsEmpty(str) ([str isKindOfClass:[NSNull class]] || str == nil || [str length] < 1 ? YES : NO )
//数组是否为空
#define kArrayIsEmpty(array) (array == nil || [array isKindOfClass:[NSNull class]] || array.count == 0)
//字典是否为空
#define kDictIsEmpty(dic) (dic == nil || [dic isKindOfClass:[NSNull class]] || dic.allKeys == 0)

//是否是空对象
#define kObjectIsEmpty(_object) (_object == nil \
|| [_object isKindOfClass:[NSNull class]] \
|| ([_object respondsToSelector:@selector(length)] && [(NSData *)_object length] == 0) \
|| ([_object respondsToSelector:@selector(count)] && [(NSArray *)_object count] == 0))


//  主要单例
#define UserDefaults_wl                        [NSUserDefaults standardUserDefaults]
#define NotificationCenter_wl                  [NSNotificationCenter defaultCenter]
#define SharedApplication_wl                   [UIApplication sharedApplication]


#ifdef DEBUG
#define NSLog(FORMAT, ...) \
fprintf(stderr,"[%s][%d]======>%s\n",\
__func__,\
__LINE__,\
[[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]\
);
#else
#define NSLog(FORMAT,...)
#endif
#define WLLog NSLog(@"%@-%s",self.class, __FUNCTION__);
